require 'redmine'
require_dependency 'members_controller'

module MembersControllerHookExportHtpasswd

  def self.included(base) # :nodoc:
    base.send(:include, InstanceMethods)

    base.class_eval do
      alias_method_chain :new, :export_htpasswd
      alias_method_chain :edit, :export_htpasswd
      alias_method_chain :destroy, :export_htpasswd
    end
  end

  module InstanceMethods
    def new_with_export_htpasswd
      new_without_export_htpasswd
      ExportHtpasswd.export
    end

    def edit_with_export_htpasswd
      edit_without_export_htpasswd
      ExportHtpasswd.export
    end

    def destroy_with_export_htpasswd
      destroy_without_export_htpasswd
      ExportHtpasswd.export
    end

  end

end
